let Service = require('node-windows').Service;
 
let svc = new Service({
   name: 'cheliang',    //服务名称
   description: '圖片下載', //描述
   script: './express.js', //nodejs项目要启动的文件路径,
   wait:'1',
   grow:'0.25',
   maxRestarts:'40'
});
// 監聽安裝
svc.on('install', () => {
   svc.start();
   console.log('install compate',svc)
});
// 監聽卸載
svc.on('uninstall', () => {
    console.log('Uninstall compate')
 });

 // 防止程序二次運行
 svc.on('alreadyinstalled', () => {
    
    console.log('this server is already installed')
 });

 if(svc.exists) return svc.uninstall

 

svc.install();
